package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.MessageSend;
import com.micro.modual.extension.MessageSendExtension;
import com.micro.modual.mapper.MessageSendMapper;
import com.micro.modual.model.bo.messagesend.MessageSendBO;
import com.micro.modual.service.MessageSendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>消息发送表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("messageSendService")
public class MessageSendServiceImpl extends AbstractBasicsServiceImpl<MessageSend,Long> implements MessageSendService {

    @Autowired
    private MessageSendMapper messageSendMapper;

    /**
     * <h2>新增消息发送表详情</h2>
     * @param messageSendBO {@link MessageSendBO} 消息发送表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addMessageSend(MessageSendBO messageSendBO) {
        MessageSend messageSend = MessageSendExtension.converAddMessageSend(messageSendBO);
        messageSendMapper.insertSelective(messageSend);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改消息发送表详情</h2>
     * @param messageSendBO  {@link MessageSendBO} 消息发送表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editMessageSend(MessageSendBO messageSendBO) {
        MessageSend messageSend = MessageSendExtension.converEditMessageSend(messageSendBO);
        messageSendMapper.updateByPrimaryKeySelective(messageSend);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除消息发送表信息</h2>
     * @param id  消息发送表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteMessageSend(Long id) {
        messageSendMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
